<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 
	<head> 
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
			<title>开心赚宝到柜类验证码</title>
			<style type="text/css">
				body{
					width: 960px;
					margin: 0 auto;
				}
				h1 {
					font-size: 14px;
				}
				table {
					margin-top: 50px;
				}
				th, td{
					width: 150px;
					overflow:hidden;
					text-align: center;
				}
				.error {
					color: red;
					font-size: 14px;
					margin-top: 50px;
				}
			</style>
	</head>
	<body>
		<h1>开心赚宝验证码查询后台</h1>
		<form name="form1" method="post" id="form1">
			<label for="captcha">请输入验证码:</label>
			<input type="text" id="captcha" name="captcha" value="<?php echo $captcha;?>" />
			<input type="submit" value="载入中奖信息" />
		</form>
		 
		<?php if (!empty($error_msg)){ ?>
		<div class="error"><?php echo $error_msg;?></div>
		<?php } ?>

		<?php if(!empty($info)) { ?>
		<table id="info" class="info">
			<tr>
				<th>中奖宝贝</th> <th>姓名</th> <th>生日</th> <th>手机号码</th> <th>用户名</th> <th>省份</th> <th>城市</th> <th>地址/邮编</th> <th>中奖时间</th> <th>操作</th>
			</tr>
			<tr>
				<td><?php echo $info['product_name'];?></td>
				<td><?php echo $info['real_name'];?></td>
				<td><?php echo $info['birthday'];?></td>
				<td><?php echo $info['phone'];?></td>
				<td><?php echo $info['name'];?></td>
				<td><?php echo $info['province'];?></td>
				<td><?php echo $info['city'];?></td>
				<td><?php echo $info['address'].'/'.$info['zipcode'];?></td>
				<td><?php echo $info['create_time'];?></td>
				<td><a href="#" id="confirm" title="确认用户已领奖">已领奖</a></td>
				<input type="hidden" id="cid" value="<?php echo $info['cid'];?>" />
			</tr>
		</table>
		<?php } ?>
	</body>
	<script type="text/javascript" src="http://sina.try8.info/webroot//js/mootools-yui-compressed.js"></script>
	<script type="text/javascript">
	var cf_func = function(){
		if (!confirm("确定已领奖？")){
			return false;
		}

		if (!$('cid')){
			alert("修改失败");
			return false;
		}

		var cid = $('cid').value;
		var captcha = $('captcha').value;

		var jsonRequest = new Request({
			url: 'product/checkCaptcha',
			onFail: function(){
				alert("修改失败，请稍候再试");
			},
			onSuccess: function(text){
				alert(text);
				$('info').setStyle('display', 'none');
			},
			method: 'post',
			data: 'action=update&captcha='+captcha+'&cid='+cid
			}).send();

		return false; // not go to href

	};
	window.addEvent('domready',function(){
		if ($('confirm')){
			$('confirm').addEvent('click', cf_func);
		}
	});
	</script>
</html>
